home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / batch / tsbat36.zip / DELDIR.BAT < prev    next >
DOS Batch File  |  1991-01-22  |  2KB  |  71 lines

  1. echo off
  2. echo.
  3. echo ┌────────────────────────────────────────────────────┐
  4. echo │ Delete a directory with all its files              │
  5. echo │ By Prof. Timo Salmi, ts@chyde.uwasa.fi, 22-Jan-91  │
  6. echo └────────────────────────────────────────────────────┘
  7. echo.
  8.  
  9. if "%1"=="" goto _help
  10.  
  11. rem Change the directory-name parameter to upper case
  12. set _stash=%path%
  13. path %1
  14. set _dir=%path%
  15. path %_stash%
  16. set _stash=
  17.  
  18. rem Checks
  19. if "%_dir%"=="\" goto _isroot
  20. if not exist %_dir%\nul goto _notexist
  21. if not exist %_dir%\*.* goto _nofiles
  22.  
  23. rem The deletion process
  24. cd %_dir%
  25. cd
  26. echo Delete the files from directory %_dir%
  27. del *.*
  28. if exist *.* goto _err1
  29. cd ..
  30. echo Break to quit, any other key to remove directory %_dir%
  31. pause > nul
  32. rmdir %_dir%
  33. if not exist %_dir%\nul echo Directory %_dir% has been deleted
  34. goto _out
  35.  
  36. :_isroot
  37. echo Deleting the root directory %_dir% is not allowed
  38. goto _out
  39.  
  40. :_notexist
  41. echo Directory %_dir% not found
  42. goto _out
  43.  
  44. :_nofiles
  45. echo No files in directory %_dir%
  46. goto _out
  47.  
  48. :_err1
  49. echo Warning: Some or all files in %_dir% still remain
  50. echo Directory still exists
  51. cd ..
  52. goto _out
  53.  
  54. :_help
  55. echo         Usage: DELDIR [DirectoryName]
  56. echo.
  57. echo      ╔═════════════════════════════════╗
  58. echo      ║ Be extra careful with this one. ║
  59. echo      ║ See the contents and make sure  ║
  60. echo      ║ you understand what is done.    ║
  61. echo      ╚═════════════════════════════════╝
  62. echo.
  63. echo If you get an "Out of environment space" message, increase your
  64. echo environment space by using shell configuration in config.sys:
  65. echo Example: shell=c:\bin\command.com /e:1024 /p
  66. echo.
  67.  
  68. :_out
  69. set _dir=
  70. echo on
  71.